package org.example.flink.operation;

import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

public class Hello08TransformationReduce {
    public static void main(String[] args) throws Exception {
        //运行环境
        StreamExecutionEnvironment environment = StreamExecutionEnvironment.getExecutionEnvironment();
        environment.setParallelism(1);
        //操作数据
        DataStreamSource<String> source = environment.fromElements("a", "aa", "b", "bb", "c", "cc");

        source.keyBy(word -> word.length()).reduce((v1, v2) -> v1 + "," + v2).print();

        //运行环境
        environment.execute();
    }
}
